package com.framework.network.annotations

import java.lang.annotation.Documented
import java.lang.reflect.Method

/**
 * @ClassName: RootDomain
 * @Description: 自定义注解，设置根域名
 * @Author: you
 */
@Documented
@Target(
    AnnotationTarget.FUNCTION,
    AnnotationTarget.PROPERTY_GETTER,
    AnnotationTarget.PROPERTY_SETTER
)
@Retention(AnnotationRetention.RUNTIME)
annotation class RootDomain(val rootDomain: String)

/**
 * 获取自定义的域名注解
 */
fun getRootDomain(method: Method): RootDomain? {
    val annotations = method.annotations
    for (annotation in annotations) {
        if (annotation is RootDomain) {
            return annotation
        }
    }
    return null
}

/**
 * 获取注解对应的值
 */
fun getRootDomain(setRootDomain: RootDomain): String? {
    return setRootDomain.rootDomain
}